package com.zyz.K_集合.Iterator迭代器;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class TestIterator4 {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
        collection.add(1);
        collection.add(2);
        collection.add(3);
        collection.add(4);
        collection.add(5);
        collection.add(6);
        collection.add(7);
        collection.add(8);
        collection.add(9);
        collection.add(10);

        Iterator iterator = collection.iterator();
        while (iterator.hasNext()) {
            Integer next = (Integer) iterator.next();
            if (next % 2 == 1) {
                iterator.remove();
            }
        }
        System.out.println(collection);
    }
}
